﻿using Anke.SHManage.BLL;
using Anke.SHManage.MSSQLDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web
{
    public partial class LS_ZDTFXZHSGModeWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.ReportViewer1.LocalReport.EnableHyperlinks = true;
                //this.ReportViewer1.LocalReport.HyperlinkTarget = "_blank";
                InitPage();

            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();
        }
        private void InitPage()
        {
            this.StartDate.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 07:30:00");
            this.EndDate.Text = DateTime.Now.ToString("yyyy-MM-dd 07:30:00");
        

            BindReportDataSource();
        }   
 
           protected void BindReportDataSource()
         {
             DateTime start = Convert.ToDateTime(this.StartDate.Text);
             DateTime end = Convert.ToDateTime(this.EndDate.Text);
             string start1 = start.ToString();
             string end1 = end.ToString();
               //获取本页路径，截取虚拟路径， 作为参数传递给需跳转页面作为URL
             string req_url = this.Request.Url.ToString();
             int pos = req_url.IndexOf("/Reports");
             string current_virtual_path = "";
             if (pos > 0)
             {
                 current_virtual_path = req_url.Substring(0, pos);
             }


             this.ReportViewer1.LocalReport.DataSources.Clear();
             this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/LS_ZDTFXZHSG.rdlc");
             Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("StartTime", start1);
             Microsoft.Reporting.WebForms.ReportParameter ed = new Microsoft.Reporting.WebForms.ReportParameter("EndTime", end1);
             Microsoft.Reporting.WebForms.ReportParameter vurl = new Microsoft.Reporting.WebForms.ReportParameter("VirtualURL", current_virtual_path);
             this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st, ed, vurl });
             string eventDispatchCenterID = UserOperateContext.Current.Seesion_Dispatch_SubCenterID; //2020-11-22 zch 登录人所处急救中心
               LSDAL dal = new LSDAL();
               DataTable dt = dal.Get_LS_ZDTFXZHSG(start, end, eventDispatchCenterID);
                     this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForLS_ZDTFXZHSG", dt));
           this.ReportViewer1.LocalReport.Refresh();
           }  
    }
}